package efr.util;

import org.quartz.JobDetail;
import org.quartz.Scheduler;
import org.quartz.SchedulerException;
import org.quartz.SchedulerFactory;
import org.quartz.SimpleScheduleBuilder;
import org.quartz.Trigger;
import org.quartz.TriggerBuilder;
import org.quartz.impl.StdSchedulerFactory;

import static org.quartz.JobBuilder.*;

public class QuartzTest {

	public void startJob() {
		try {
//			Scheduler scheduler = StdSchedulerFactory.getDefaultScheduler();
			SchedulerFactory sf = new StdSchedulerFactory();
			Scheduler scheduler = sf.getScheduler();
			
			JobDetail job = newJob(HelloJob.class).withIdentity("job1", "group1").build();
			Trigger trigger = TriggerBuilder.newTrigger().withIdentity("trigger1", "group1").startNow().withSchedule(SimpleScheduleBuilder.simpleSchedule().withIntervalInSeconds(180).repeatForever()).build();

			scheduler.scheduleJob(job, trigger);
			scheduler.start();
//			Thread.sleep(90L * 1000L);
//			scheduler.shutdown();
		} catch (SchedulerException e) {
			e.printStackTrace();
		} 

	}

}
